
// 热门品牌-店铺首页
function rm_shop_i() {
    let mockData = Mock.mock({
        'bigimg1': "@image('1720x540',#eac7ce)",
        'bigimg2': "@image('1720x540',#eac7ce)",
        "couponlist|3": [{
            'cutprice': "5",
            'condition': "99",
            'expiredate': "2017.12.12~2017.12.12"
        }],
        'cate1': {
            'img1': "@image('390x284',#bdc7ce)",
            'img2': "@image('390x566',#cac9ce)",
            'img3': "@image('390x566',#dac7ce)",
            'img4': "@image('390x284',#eab7ce)",
            'img5': "@image('390x284',#fac7cf)",
            'img6': "@image('390x566',#aac7ce)",
        },
        'cate2': {
            'img1': "@image('200x338',#bdc7ce)",
            'img2': "@image('200x338',#cac9ce)",
            'img3': "@image('200x338',#dac7ce)",
            'img4': "@image('146x168',#eab7ce)",
            'img5': "@image('146x168',#fac7cf)",
            'img6': "@image('146x168',#aac7ce)",
            'img7': "@image('146x168',#bac7ce)",
            'img8': "@image('146x168',#cac7ce)",
            'img9': "@image('146x168',#dac7ce)",
            'img10': "@image('146x168',#eac7ce)",
            'img11': "@image('146x168',#fac7ce)",
        },
        'cate3': {
            'item1': {
                'img': "@image('535x746',#bdc7ce)",
                'title': "条纹长轴针织衫",
                'price': 600
            },
            'item2': {
                'img': "@image('479x666',#adc7ce)",
                'title': "双排扣双面呢外套 ",
                'price': 900
            },
            'item3': {
                'img': "@image('398x584',#bdc7ce)",
                'title': "条纹长轴针织衫",
                'price': 600
            },
            'item4': {
                'img': "@image('617x584',#bdc7ce)",
                'title': "条纹长轴针织衫",
                'price': 900
            },
            'item5': {
                'img': "@image('618x585',#bdc7ce)",
                'title': "双排扣双面呢外套 ",
                'price': 600
            },
            'item6': {
                'img': "@image('398x585',#bdc7ce)",
                'title': "条纹长轴针织衫",
                'price': 900
            }
        },
        "prolist|10": [{
            'img': "@image('224x286',#eac7ce)",
            'title': "@ctitle(20, 35)",
            'sellcount|100-600': 1,
            'price|100-600.2': 1
        }],
        "navlist|8": [{
            "text": "@ctitle(2,4)",
            "href": "#"
        }]
    });
    new Vue({
        el: '#rm_shop_i',
        data() {
            return {
                shopInfo: null,
                logobanner: null,
                navlist: null,
                fileprefix:null,
                shopDecoration:{},
                productList:[],
                bigimg1:[],
                bigimg2:[],
                shopTemplateList:[],
                couponlist:[]
            }
        },
        components: {
            'coupon-list': shop_coupon_list,
            'pro-list': rm_shop_i_pro_list
        },
        methods: {
            getData() {
                let that = this;
                var href = urlParam.href();
                this.navlist = mockData.navlist;
                //店铺基本信息
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shop/shopInfo?id=' + href.businessId,
                    responseType: 'stream',
                }).then(function(response) {
                    if(response.data.code == 1){
                        that.logobanner = response.data.data.pcBackground;
                        that.shopInfo = response.data.data;
                    }
                });
                //店铺装修信息
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shopDecoration/pclist?userId=' + href.businessId,
                    responseType: 'stream',
                }).then(function(response) {
                    that.fileprefix = response.data.data.fileprefix;
                    that.shopDecoration = response.data.data.shopDecoration;
                    if(that.shopDecoration != null){
                        that.couponlist = that.shopDecoration.couponManageList;
                        that.productList = that.shopDecoration.productList;
                        that.shopTemplateList = that.shopDecoration.shopTemplateList;
                    }
                })

                //头部大图
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shopDecoration/bigimg?userId='+ href.businessId +'&prcIndex=0',
                    responseType: 'stream',
                }).then(function(response) {
                    that.fileprefix = response.data.data.fileprefix;
                    that.bigimg1 = response.data.data.shopDecorationPictureList;
                }).then(function() {
                    that.initSwipterBanner();
                });


                //中间大图
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shopDecoration/bigimg?userId='+ href.businessId +'&prcIndex=1',
                    responseType: 'stream',
                }).then(function(response) {
                    that.fileprefix = response.data.data.fileprefix;
                    that.bigimg2 = response.data.data.shopDecorationPictureList;
                });

                //this.bigimg1 = mockData.bigimg1;
                //this.bigimg2 = mockData.bigimg2;
                //this.couponlist = mockData.couponlist;
                //this.cate1 = mockData.cate1;
                //this.cate2 = mockData.cate2;
                //this.cate3 = mockData.cate3;
                //this.prolist = mockData.prolist;
            },
            initSwipterBanner() {
                var swiper = new Swiper('.indextuan_banner', {
                    speed: 1000, //滑动速度，即slider自动滑动开始到结束的时间（单位ms），也是触摸滑动时释放至贴合的时间
                    autoplay: 6000, //可选选项，自动滑动
                    autoplayDisableOnInteraction: false, //用户操作swiper之后，是否禁止autoplay。默认为true：停止
                    loop: true, //让Swiper看起来是循环的。
                    effect: 'fade', //默认为" slide "（位移切换），可设置为" fade " 淡入 "  cube " 方块  " coverflow " 3d流  " flip " 3d翻转 。
                    //分页器
                    pagination: '.swiper-pagination', //设置分页器，默认null
                    paginationType: 'bullets', //分页器样式类型 ‘bullets’  圆点（默认）‘fraction’  分式  ‘progress’  进度条
                    paginationClickable: true, //点击分页器的指示点分页器会控制Swipe

                    lazyLoading: true, //设为true开启图片延迟加载
                    lazyLoadingInPrevNext: true, //设置为true允许将延迟加载应用到最接近的slide的图片（前一个和后一个slide）
                });
            },
        },
        created() {
            this.getData();
        },
        mounted() {
            this.initSwipterBanner();
        },
    })
}

// 热门品牌-店铺首页-产品单项
let rm_shop_i_pro_item = {
    props: ['pro'],
    template: `<div class="rm-shop-i-pro-item">
        <div><a href="javascript:;"><img :src="pro.img"></a></div>
        <a href="javascript:;"><p class="pro-title">{{pro.title}}</p></a>
        <p class="pro-info">
            <span>￥<span class="pro-price">{{pro.price}}</span></span>
            <span class="pro-sellcount"> 总销量：{{pro.sellcount}}</span>
        </p>
    </div>`
}

// 热门品牌-店铺首页-产品列表
let rm_shop_i_pro_list = {
    props: ['prolist'],
    template: `<div class="rm-shop-i-products">
        <pro-item v-for="(pro,index) in prolist" :key="index" :pro="pro"></pro-item>
    </div>`,
    components: {
        'pro-item': rm_shop_i_pro_item
    }
}

// 热门品牌-店铺-全部商品
function rm_shop_all() {
    let mockData = Mock.mock({
        'topimg': "@image('1920x360',#eac7ce)",
        "prolist|10": [{
            'img': "@image('214x274',#eac7ce)",
            'title': "@ctitle(5, 10)",
            'sellprice|100-200.2': 239.00,
            'manjian|0-1': 0,
            'baoyou|0-1': 0
        }],
    });
    new Vue({
        el: '#rm_shop_new',
        data() {
            return {
                shopInfo: null,
                logobanner: null,
                navlist: null,
                prolist:null,
                count:0,
                pages:0
            }
        },
        components: {
            'pro-list': base_product_list
        },
        methods: {
            getData() {
                let that = this;
                var href = urlParam.href();
                this.topimg = mockData.topimg;

                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shop/shopInfo?id=' +href.businessId,
                    responseType: 'stream',
                }).then(function(response) {
                    if(response.data.code == 1){
                        that.logobanner = response.data.data.pcBackground;
                        that.shopInfo = response.data.data;
                    }
                });

                //获取全部商品
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shop/commodityListPc',
                    params: {
                        userId: href.businessId,
                        productId: that.pages,
                        pagesize: 10,
                        salesVolumeSort:"desc"
                    },
                }).then(function(response) {
                    if(response.data.code == 1){
                        that.prolist = response.data.data.commodityList;
                        that.count = getPageCount(response.data.data.count,10);
                    }
                });
            },
            listen: function(data) {
                let that = this;
                // 翻页事件
                that.pages = data - 1;
                this.getData();
            }
        },
        created() {
            this.getData();
        }
    })
}

// 热门品牌-店铺-新品
function rm_shop_new() {
    let mockData = Mock.mock({
        'topimg': "@image('1920x360',#eac7ce)",
        "prolist|10": [{
            'img': "@image('214x274',#eac7ce)",
            'title': "@ctitle(5, 10)",
            'sellprice|100-200.2': 239.00,
            'manjian|0-1': 0,
            'baoyou|0-1': 0
        }],
    });
    new Vue({
        el: '#rm_shop_new',
        data() {
            return {
                shopInfo: null,
                logobanner: null,
                navlist: null,
                prolist:null,
                count:0,
                pages:0,
                topimg:null,
                fileprefix:null
            }
        },
        components: {
            'pro-list': base_product_list
        },
        methods: {
            getData() {
                let that = this;
                var href = urlParam.href();
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shop/shopInfo?id=' +href.businessId,
                    responseType: 'stream',
                }).then(function(response) {
                    if(response.data.code == 1){
                        that.logobanner = response.data.data.pcBackground;
                        that.shopInfo = response.data.data;
                    }
                });

                //获取上新商品
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shop/getNewCommodityListPc',
                    params: {
                        userId: href.businessId,
                        productId: that.pages,
                        pagesize: 10,
                        salesVolumeSort:"desc"
                    },
                }).then(function(response) {
                    if(response.data.code == 1){
                        that.prolist = response.data.data.commodityList;
                        that.count = getPageCount(response.data.data.count,10);
                    }
                });

                //头部大图
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shopDecoration/bigimg?userId='+ href.businessId +'&prcIndex=2',
                    responseType: 'stream',
                }).then(function(response) {
                    console.log(response.data.data);
                    that.fileprefix = response.data.data.fileprefix;
                    that.topimg = response.data.data.shopDecorationPictureList;
                });
            },
            listen: function(data) {
                let that = this;
                // 翻页事件
                that.pages = data - 1;
                this.getData();
            }
        },
        created() {
            this.getData();
        }
    })
}

// 热门品牌
function rm_pinpai() {
    let mockData = Mock.mock({
        'topimg': "@image('1920x360',#eac7ce)",
        // "pplist": [{
        //     'title': '女装热门品牌',
        //     'desc': 'Women’s fashion brands',
        //     'shoplist|18': [{
        //         'thumb': "@image('175x169',#eac7ce)",
        //         'logo': "@image('120x30',#aac7ce)",
        //         'name': "@ctitle(3, 4)",
        //     }]
        //
        // }, {
        //     'title': '男装热门品牌',
        //     'desc': 'Men’s fashion brands',
        //     'shoplist|18': [{
        //         'thumb': "@image('175x169',#eac7ce)",
        //         'logo': "@image('120x30',#aac7ce)",
        //         'name': "@ctitle(3, 4)",
        //     }]
        //
        // }],
    });
    new Vue({
        el: '#rm_pinpai',
        data() {
            return {
                pplist: [],
                topnavlist: {},
                topimg: null
            }
        },
        components: {
            'pinpai-list': rm_pinpai_shop_box,
        },
        methods: {
            getData() {
                var that = this;
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/brand/brandSort',
                    responseType: 'stream',
                }).then(function(response) {
                    that.pplist = response.data.data;
                });

                axios({
                    method: 'get',
                    url: urlParam.domain() + '/api/ad/adOnePC?adPostionId=38',
                    responseType: 'stream'
                }).then(function(response) {
                    that.topimg = response.data.data.list;
                });
                //this.topimg = mockData.topimg;
                // this.pplist = mockData.pplist;
            },
        },
        created() {
            this.getData();
        }
    })
}

// 热门品牌-品牌单项
let rm_pinpai_shop_item = {
    props: ['shop'],
    template: `<div class="shop-item">
        <a :href="shop.pcShopUrl">
        <img :src="shop.background">
        <div class="shop-info">
           <p class="name" style="color: white;">{{shop.name}}</p>
        </div>
        </a>
    </div>`
}

// 热门品牌-品牌列表
let rm_pinpai_shop_list = {
    props: ['shoplist'],
    template: `<div class="shop-list">
        <shop-item v-for="(item,index) in shoplist" :key="index" :shop="item"></shop-item>
    </div>`,
    components: {
        'shop-item': rm_pinpai_shop_item
    }
}

// 热门品牌-品牌分类
let rm_pinpai_shop_box = {
    props: ['pplist'],
    template: `<div>
        <div v-for="(box,index) in pplist" :key="index" class="rm-pp-shop-box" v-if="box.name">
            <div class="shop-title">
                {{box.name}}
                <span class="shop-desc">{{box.pageInfo}}</span>
            </div>
            <shop-list :shoplist="box.productBrands"></shop-list>
            <!--<div class="more-wrap">-->
                <!--更多品牌<div class="i-wrap"><i class="icon-rm-arr-down"></i></div>-->
            <!--</div>-->
        </div>
    </div>`,
    components: {
        'shop-list': rm_pinpai_shop_list
    }
}

// 热门品牌-店铺促销
function rm_shop_cuxiao() {
    let mockData = Mock.mock({
        'bigimg1': "@image('1920x360',#eac7ce)",
        "couponlist|3": [{
            'cutprice': "5",
            'condition': "99",
            'expiredate': "2017.12.12~2017.12.12"
        }],
        "cuxiaolist|2": [{
            'name': '满500减100元',
            'date': '2017/12/25—2017/12/26',
            'prolist|10': [{
                'img': "@image('214x274',#eac7ce)",
                'title': "@ctitle(5, 10)",
                'sellprice|100-200.2': 239.00,
                'manjian|0-1': 0,
                'baoyou|0-1': 0
            }]
        }]
    });
    new Vue({
        el: '#rm_shop_cuxiao',
        data() {
            return {
                shopInfo: null,
                logobanner: null,
                navlist: null,
                cuxiaolist:null,
                couponlist:null,
                topimg:null,
                fileprefix:null
            }
        },
        components: {
            'coupon-list': shop_coupon_list,
            'pro-list': base_product_list,
        },
        methods: {
            getData() {
                let that = this;
                var href = urlParam.href();
                this.topimg = mockData.topimg;
                this.prolist = mockData.prolist;
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shop/shopInfo?id=' +href.businessId,
                    responseType: 'stream',
                }).then(function(response) {
                    if(response.data.code == 1){
                        that.logobanner = response.data.data.pcBackground;
                        that.shopInfo = response.data.data;
                    }
                });

                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shop/getSaleActivityListPc?userId=' +href.businessId,
                    responseType: 'stream',
                }).then(function(response) {
                    if(response.data.code == 1){
                        that.cuxiaolist = response.data.data.saleActivityProductList;
                        that.couponlist = response.data.data.couponManageList;
                    }
                });

                //头部大图
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/shopDecoration/bigimg?userId='+ href.businessId +'&prcIndex=3',
                    responseType: 'stream',
                }).then(function(response) {
                    that.fileprefix = response.data.data.fileprefix;
                    that.topimg = response.data.data.shopDecorationPictureList;
                });

                //this.cuxiaolist = mockData.cuxiaolist;
                //this.couponlist = mockData.couponlist;
            },
        },
        created() {
            this.getData();
        }
    })
}